home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
mscheap2
/
watch.c
< prev
Wrap
C/C++ Source or Header
|
1990-03-07
|
1KB
|
44 lines
#include <stdio.h>
#include <heap.h>
//
// Example of _heapwatch from heap.man
//
void report( char *position );
int main()
{
int index;
char far *ptr = _fmalloc( 100 );
for ( index=0 ; index<100 ; index++ )
ptr[index] = (char) index;
_fheapwatch( ptr, 1 ); // establishes the enty as read-only
report( "read-only enabled" ); // should not detect an error
ptr[0] = -1; // change part of the data
report( "data modified" ); // should detect an error
_fheapwatch( ptr, 0 ); // stop watching this region
report( "read-only disabled" ); // should not detect an error
return( 0 );
}
void report( char *position )
{
int status = _fheapchk();
printf( "Heap status after %s : %s\n", position, _heapstat(status) );
}